package org.example.spring.self.demo.s4;

import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor;
import org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver;
import org.springframework.context.support.GenericApplicationContext;

/**
 * 文件描述
 *
 * @author yezhou41127
 * @date: 2022年08月01日
 */
public class TestApplication4 {

	public static void main(String[] args) {
		// 一个干净的容器
		GenericApplicationContext context = new GenericApplicationContext();

		context.registerBean("bean1", Bean1.class);
		context.registerBean("bean2", Bean2.class);
		context.registerBean("bean3", Bean3.class);

		// @Autowired @Value
		context.getDefaultListableBeanFactory()
				.setAutowireCandidateResolver(new ContextAnnotationAutowireCandidateResolver());
		context.registerBean(AutowiredAnnotationBeanPostProcessor.class);
		// @Resource @PostConstruct @PreDestroy
		context.registerBean(CommonAnnotationBeanPostProcessor.class);
//		ConfigurationPropertiesBindingPostProcessor

		// 初始化容器
		context.refresh();

		context.close();
	}
}
